/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-25
 */
public class Main {
    public static void main(String[] args) {
/*        Runtime runtime = Runtime.getRuntime();
        int count = runtime.availableProcessors();
        System.out.println(count);*/

/*        Person person = new Person();
        person.start();*/
        Thread t1 = new Thread(new Person1());
        t1.start();

        int count = 0;
        while (true) {
            try {
                Thread.sleep(100);
                System.out.println("主线程线程执行中" + (++count) + Thread.currentThread().getName());
            } catch(InterruptedException e) {
                e.printStackTrace();
            }
            if (count >= 30) {
                break;
            }
        }
    }
}

class Person extends Thread{
    @Override
    public void run() {
        int count = 0;
        while (true) {
            try {
                Thread.sleep(500);
                System.out.println("我是一个子线程" + (++count) + Thread.currentThread().getName());
            } catch(InterruptedException e) {
                e.printStackTrace();
            }
            if (count >= 30) {
                break;
            }
        }
    }
}

class Person1 implements Runnable{
    @Override
    public void run() {
        int count = 0;
        while (true) {
            try {
                Thread.sleep(500);
                System.out.println("我是一个子线程" + (++count) + Thread.currentThread().getName());
            } catch(InterruptedException e) {
                e.printStackTrace();
            }
            if (count >= 30) {
                break;
            }
        }
    }
}